
cc.Class({
    extends: cc.Component,

    properties: {
        bg1: cc.Sprite,
        bg2: cc.Sprite,
        speed: 1,
        _w: null,
    },


    onLoad() {
        this.speed = 2;
        this._w = cc.winSize.width;
        this.bg2.node.x = this.bg1.node.x + this.bg1.node.getContentSize().width;
        console.log(this.node.getContentSize());


    },

    start() {

    },

    update(dt) {
        var _w = this._w;
        let speed = this.speed;
        this.bg2.node.x -= speed;
        this.bg1.node.x -= speed;
        if (this.bg2.node.x < -_w) {
            this.bg2.node.x = this.bg1.node.x + this.bg1.node.getContentSize().width;
        }
        if (this.bg1.node.x < -_w) {
            this.bg1.node.x = this.bg2.node.x + this.bg1.node.getContentSize().width;

        }

    },
});
